<template>
    <div class="commission-detail-tem">
        <div class="commission-list-box">
            <div class="list-detail" v-for="(item,index) in detailList" :key="index" @click="toComDetail(item.id)">
                <div class="left">
                    <span>{{item['create_time']}}</span>
                    <!-- <span>{{item.time}}</span> -->
                </div>
                <div class="middle">
                    <img src="~assets/icons/income_up.png" alt="">
                    <!-- <img src="~assets/icons/income_down.png" alt="" v-show="item.income <= 0"> -->
                    <div class="income">
                        <span>+</span>
                        <span>{{item.commission}}</span>
                    </div>
                </div>
                <div class="right">
                    <span v-if="item.pid == 1">一级分销</span>
                    <span v-if="item.pid == 2">二级分销</span>
                    <span v-if="item.pid == 3">三级分销</span>
                    <img src="~assets/icons/arrow.png" alt="">
                </div>
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name:'commissionDetail',
    data(){
        return {
            detailList:[]
        }
    },
    methods:{
        toComDetail(id){
            this.$router.push({path:'/distribution/commission_detail_msg', query:{id:id}});
        },
        getCommission(){
            let that = this;
            let token = localStorage.getItem('token');
            let disNum = localStorage.getItem('distribution');
            let loader = that.loading();
            that.$ajax(that, 'get', that.$api.commissionDetail+disNum, null, token, function(res){
                if(res.data['error_code'] == 0){
                    that.detailList = res.data['msg'];

                }else{
                    that.toast(res.data['msg']);
                }
                loader.close();
            })
        }
    },
    mounted(){
        this.$store.state.tab = '佣金明细';
        this.getCommission();
    },
    activated(){
        this.$store.state.tab = '佣金明细';
        this.getCommission();
    }
}
</script>

<style lang='less'>
@rem:100rem;

.commission-detail-tem{
    width: 750/@rem;
    margin-top: 88/@rem;
    .commission-list-box{
        padding-top: 20/@rem;
        .list-detail{
            width: 100%;
            height: 80/@rem;
            box-sizing: border-box;
            padding: 0 30/@rem;
            display: flex;
            background: #ffffff;
            border-bottom: 1px solid #e5e5e5;
            .left{
                width: 224/@rem;
                height: 100%;
                display: flex;
                flex-direction: column;
                justify-content: center;
                align-items: flex-start;
            }
            .middle{
                width: 242/@rem;
                height: 100%;
                display: flex;
                align-items: center;
                img{
                    width: 34/@rem;
                    height: 38/@rem;
                    margin-left: 40/@rem;
                }
                .income{
                    margin-left: 20/@rem;
                    text-align: start;
                    span:nth-of-type(1){
                        margin-right: -6/@rem;
                    }
                }
            }
            .right{
                width: 224/@rem;
                height: 100%;
                display: flex;
                align-items: center;
                justify-content: flex-end;
                img{
                    height: 38/@rem;
                    width: 38/@rem;
                }
            }
        }
    }
}
</style>
